#!/bin/bash

# 如果当前系统是CentOS 则用yum下载keepalived 反之用apt
if [ -f /etc/centos-release ] ||
   { [ -f /etc/redhat-release ] && grep -qi "centos" /etc/redhat-release; } ||
   { [ -f /etc/os-release ] && (grep -q "ID=\"centos\"" /etc/os-release || grep -q "ID=centos" /etc/os-release); }; then
    yum install keepalived.x86_64 1.3.5-19.el7
else
    apt install keepalived=1:2.0.19-2ubuntu0.2 -y
fi

INSTALL_PATH="/home/gonsin/venus/hotStandbyStatusMonitor"
if [ ! -d $INSTALL_PATH ]; then
   mkdir $INSTALL_PATH
fi

# 下载python窗口程序依赖
pip3 install PySide6

cp -f start.sh $INSTALL_PATH/
cp -f hotStandbyStatusMonitor.py $INSTALL_PATH/

chmod 755 $INSTALL_PATH/start.sh
chmod 755 $INSTALL_PATH/hotStandbyStatusMonitor.py

cp -f hotStandbyStatusMonitor.service /etc/systemd/system/

chmod 755 /etc/systemd/system/hotStandbyStatusMonitor.service

systemctl daemon-reload

systemctl enable hotStandbyStatusMonitor.service

systemctl start hotStandbyStatusMonitor.service